<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" type="text/css" href="/static/css/jquery.mobile-1.4.5.min.css">
<script type="text/javascript" src="/static/js/jquery-2.0.0.min.js"></script>
<script type="text/javascript" src="../static/js/jquery.mobile-1.4.5.min.js"></script>
<script type="text/javascript" src="/static/js/myinit.js"></script>
<title>客服登录</title>
</head>

<body>
<div data-role="page" id="login">
	<div role="main" class="ui-content">
		<input id="NAME" type="text" placeholder="客服登录名"/>
		<input id="PASSWORD" type="password" placeholder="客服登录密码"/>
		<a class="ui-btn ui-btn-corner-all" id="checkin">登录</a>
	
	</div>
</div>

<script type="text/javascript">
/*
客服接口：
http://127.0.0.1:8000/webserver/api/v1/servicer/?format=json&status='1'&nickname='aaaaa' 获取客服接口 (get)
签到签退需要修改登录状态
http://127.0.0.1:8000/webserver/api/v1/servicer/id/ 获取客服接口 (get)
data={'status':'2'}
*/
$('#checkin').click(function(e) {
	var name = $('#NAME').val();
	var url = '/webserver/api/v1/servicer/?format=json&nickname='+name;
	$.getJSON( url,function(rs){
		var objects =rs.objects;
		if(objects.length==0){
			toast('没有此账户');
		}
		var password = $('#PASSWORD').val();
		if(password==objects[0].password){
			var id = objects[0].id;
			checkin(id);
		}else{
			toast('密码错误');
		}
		 
		
	});
	
	
	
	
});

function checkin(id){
	var url = '/webserver/api/v1/servicer/'+id+"/";
	var aa={};
	aa.status=1;
	doput(url,aa,function(rs){
		
		var status = rs.status;
		if(status==1){
			toastwithaction('登录成功',function(){
				document.location.href = "kefuhome.html?KFID="+id;
			});
		}
		
				
	});
	
}



</script>
</body>
</html>
